//Download by http://www.NewXing.com
// DropWin.cpp : implementation file
//

#include "stdafx.h"
#include "LeoBlock2004.h"
#include "DropWin.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDropWin

CDropWin::CDropWin()
{
}

CDropWin::~CDropWin()
{
	delete m_pDropView;
}
BOOL CDropWin::CreateNew(CRect rect,CWnd* pParentWnd,UINT nID,UINT nIDMenu,DWORD dwExStyle,DWORD dwStyle)
{
	//rush nBrush(RGB(0,0,0));
	m_pParentWnd=pParentWnd;
	m_nIDMenu=nIDMenu;
//::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_HAND_1))
	//szClassName=AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,AfxGetApp()->LoadStandardCursor(IDC_ARROW),(HBRUSH)(nBrush.GetSafeHandle()),NULL);
	m_szClassName=AfxRegisterWndClass(0);
	BOOL bReturn=CreateEx(dwExStyle,m_szClassName,NULL,dwStyle,rect.left,rect.top,rect.right,rect.bottom,NULL,NULL);
	//rush.DeleteObject();
	

	
	return bReturn;
	
}

BEGIN_MESSAGE_MAP(CDropWin, CWnd)
	//{{AFX_MSG_MAP(CDropWin)
	ON_WM_SIZE()
	ON_WM_NCDESTROY()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_DROPWINPOS,OnPosWin)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CDropWin message handlers

BOOL CDropWin::ShowView()
{
	CRect nRect;
	GetClientRect(nRect);
	nRect.top+=1;
	nRect.left+=1;
	nRect.right-=1;
	nRect.bottom-=1;
	m_pDropView=new CDropView();
	BOOL bReturn=m_pDropView->CreateView(m_szClassName,nRect,this,ID_DROPVIEW);
	if(bReturn)
	{
		m_pDropView->ShowWindow(SW_SHOW);
		m_pDropView->SetWndID(m_pParentWnd,m_nIDMenu);

		return TRUE;
	}



	return FALSE;

}


void CDropWin::OnSize(UINT nType, int cx, int cy) 
{
	CWnd::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here

	
}

void CDropWin::OnPosWin(WPARAM wParam,LPARAM lParam)
{
	DROP_POS *sDropPos=(DROP_POS*)lParam;
	m_x=sDropPos->x;
	m_y=sDropPos->y;
	SetWindowPos(&CWnd::wndTopMost,m_x,m_y,0,0,SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER);

}

void CDropWin::OnNcDestroy() 
{
	CWnd::OnNcDestroy();
	
	// TODO: Add your message handler code here
	delete this;

}



BOOL CDropWin::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	CRect rect;
	GetClientRect(&rect);
	CBrush brush(RGB(255,255,255));
	pDC->FillRect(&rect,&brush);


	return CWnd::OnEraseBkgnd(pDC);
}

void CDropWin::SetTimerPaint(int nNumThread)
{
	if(nNumThread>0)
		m_pDropView->SetTimerStart(nNumThread);

}

void CDropWin::KillTimerPaint(int nNumThread)
{
	if(nNumThread<=0)
		m_pDropView->KillTimerEnd(nNumThread);

}
